home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / CENVIW2.ZIP / KEYGHOST.CMM < prev    next >
Text File  |  1993-09-13  |  2KB  |  53 lines

  1. // KeyGhost.cmm - Example for how to control other programs using the
  2. //                the keyboard stuffing routines in KeyPush.Lib.
  3.  
  4. #include <Message.lib>
  5. #include <KeyPush.lib>
  6. #include <MsgBox.lib>
  7.  
  8. // Start NotePad running
  9.    if ( -1 == spawn(P_NOWAIT,"NotePad.exe") ) {
  10.       MessageBox("ERROR: Unable to execute NotePad.exe.");
  11.       exit(1);
  12.    }
  13.  
  14. // Enter initial CEnvi sentence
  15.    SpeedKeys("CEnvi is good.");
  16.  
  17. // Change "good" to "great"
  18.    for ( i = 0; i < 5; i++ )
  19.       KeyStroke(VK_SHIFT,VK_LEFT)
  20.    SpeedKeys("great!");
  21.  
  22. // Figure out how much it costs per day for a year
  23.    SpeedKeys("\n\nIs it worth 38 dollars?\n"
  24.              "To use it every day for a year costs");
  25. // Bring up calculator to figure $38.00 / 365 * 10
  26.    if ( -1 == spawn(P_NOWAIT,"Calc.exe") ) {
  27.       MessageBox("ERROR: Unable to execute Calc.exe.");
  28.       exit(1);
  29.    }
  30.    SpeedKeys("C38.00/365=*100=");   // perform calculation
  31.    KeyStroke(VK_ALT,"EC");          // copy result into the clipboard
  32.    KeyStroke(VK_ALT,VK_F4);         // Exit the calculator
  33.  
  34. // Paste the result into NotePad then continue senctence
  35.    KeyStroke(VK_ALT,"EP");
  36.    SpeedKeys(" pennies a day.\nWhat a bargain!");
  37.  
  38. // now print the message to register
  39.    SpeedKeys("\n\nRegister now!");
  40. // copy the Register message just printed and print it many more times
  41.    KeyStroke(VK_SHIFT,VK_HOME);
  42.    KeyStroke(VK_SHIFT,VK_UP);
  43.    KeyStroke(VK_CONTROL,VK_INSERT);
  44.    KeyStroke(VK_DOWN), KeyStroke(VK_END);
  45. // print that message another 15 times
  46.    for ( i = 0; i < 7; i++ )
  47.       KeyStroke(VK_SHIFT,VK_INSERT);
  48.  
  49.  
  50. // finally, say goodbye and exit
  51.    SpeedKeys("\nThank you.");
  52.    KeyStroke(VK_ALT,"FXN");
  53.